<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('购货入库列表')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>单据编号：</label>
                            <input type="text" name="gouhuoDanhao"/>
                        </li>
                        <li>
                            <label>购货日期：</label>
                            <input type="text" class="time-input" placeholder="请选择购货日期" name="gouhuoDate"/>
                        </li>
                        <li>
                            <label>经手人：</label>
                            <input type="text" name="gouhuoJingshouren"/>
                        </li>
                        <li>
                            <label>仓库：</label>
                            <select name="gouhuoCangku"
                                    th:with="type=${@cangkuServiceImpl.selectCangkuAll()}" required>
                                <option value=""></option>
                                <option th:each="lists : ${type}"
                                        th:if="${lists.getCangkuName().equals(session.name4user)
                                        || session.QuanXian=='1' ||session.QuanXian==1}"
                                        th:text="${lists.getCangkuName()}"
                                        th:value="${lists.getCangkuName()}"
                                        ></option>
                            </select>
                        </li>
                        <li>
                            <label>商品编号：</label>
                            <input name="goodId" id="goodId" type="text" class="form-control" list="goodsid">
                            <datalist id="goodsid" th:with="type=${@shangpinxinxiServiceImpl.selectGoods4LeiBieAndName()}">
                                <option  th:each="lists : ${type}"
                                         th:text="${lists.getShangpinId()+' | '+lists.getShangpinName()}"
                                         th:value="${lists.getShangpinId()}">
                                </option>
                            </datalist>
                            <!--                                <input type="text" name="shangpinId"/>-->
                        </li>
                        <li>
                            <label>商品类别：</label>
                            <select name="shangpinLeibie"
                                    th:with="type=${@shangpinxinxiServiceImpl.selectGoods4LeiBie()}" required>
                                <option hidden value=""></option>
                                <option th:each="lists : ${type}"
                                        th:text="${lists.getShangpinLeibie()}"
                                        th:value="${lists.getShangpinLeibie()}"></option>
                            </select>
                        </li>
                        <li>
                            <label>商品名称：</label>
                            <input type="text" name="goodName"/>
                        </li>
                        <li>
                            <label>商品规格：</label>
                            <input type="text" name="goodGuige"/>
                        </li>
                        <li>
                            <label>数量：</label>
                            <input type="text" name="shuliang"/>
                        </li>
                        <li>
                            <label>底价：</label>
                            <input type="text" name="dijia"/>
                        </li>
                        <li th:if="${session.QuanXian}">
                            <label>总部底价：</label>
                            <input type="text" name="zongbudijia"/>
                        </li>
                        <li>
                            <label>金额：</label>
                            <input type="text" name="jiner"/>
                        </li>
                        <li>
                            <label>备注：</label>
                            <input type="text" name="beizhu"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div hidden id="session2value" th:text="${session.QuanXian}"></div>
        <div class="btn-group-sm" id="toolbar" role="group">
<!--            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="gouhuoruku:rukuTest:add">
                <i class="fa fa-plus"></i> 添加
            </a>-->
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="gouhuoruku:rukuTest:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="gouhuoruku:rukuTest:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="gouhuoruku:rukuTest:export">
                <i class="fa fa-download"></i> 导出
            </a>
<!--                        <a class="btn btn-success" onclick="$.operate.addMoreTab()" shiro:hasPermission="piliangruku:rukuTest:view">-->
<!--                                <i class="fa fa-plus"></i> 批量添加-->
<!--                            </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>

</div>
<!--     <script>-->
<!--         if ($.session.get('QuanXian') !== 1){-->
<!--             var zongdi = $('table[id="bootstrap-table"]').children('tbody').children('tr').children[11]-->
<!--             zongdi.empty()-->
<!--         }-->
<!--     </script>-->
<th:block th:include="include :: footer"/>

<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('gouhuoruku:rukuTest:edit')}]];
    var removeFlag = [[${@permission.hasPermi('gouhuoruku:rukuTest:remove')}]];
    var cangkuNameDatas = [[${@dict.getType('sys_job_group')}]];
    var prefix = ctx + "gouhuoruku/rukuTest";


    $(function () {
        if (document.getElementById("session2value").innerText !== "1")
        {
            $(function ()
            {
                var options = {
                    url: prefix + "/list",
                    createUrl: prefix + "/add",
                    updateUrl: prefix + "/edit/{id}",
                    removeUrl: prefix + "/remove",
                    exportUrl: prefix + "/export",
                    modalName: "购货入库",
                    columns: [{
                        checkbox: true
                    },
                        {
                            field: 'id',
                            title: '编号',
                            visible: false
                        },
                        {
                            field: 'gouhuoDanhao',
                            title: '单据编号'
                        },
                        {
                            field: 'gouhuoDate',
                            title: '购货日期'
                        },
                        {
                            field: 'gouhuoJingshouren',
                            title: '经手人'
                        },
                        {
                            field: 'gouhuoCangku',
                            title: '仓库',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(cangkuNameDatas, value);
                            }
                        },
                        {
                            field: 'goodId',
                            title: '商品编号'
                        },
                        {
                            field: 'shangpinLeibie',
                            title: '商品类别'
                        },
                        {
                            field: 'goodName',
                            title: '商品名称'
                        },
                        {
                            field: 'goodGuige',
                            title: '商品规格'
                        },
                        {
                            field: 'shuliang',
                            title: '数量'
                        },
                        {
                            field: 'dijia',
                            title: '底价'
                        },
                        {
                            field: 'jiner',
                            title: '金额'
                        },
                        {
                            field: 'beizhu',
                            title: '备注'
                        },
                        /*{
                            title: '操作',
                            align: 'center',
                            formatter: function (value, row, index) {
                                var actions = [];
                                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                                return actions.join('');
                            }
                        }*/
                    ]
                };
                $.table.init(options);
                //console.log(document.getElementById("session2value").innerText)
            });
        }
        else {
            $(function ()
            {
                var options = {
                    url: prefix + "/list",
                    createUrl: prefix + "/add",
                    updateUrl: prefix + "/edit/{id}",
                    removeUrl: prefix + "/remove",
                    exportUrl: prefix + "/export",
                    modalName: "购货入库",
                    showColumns: false,
                    showToggle: false,
                    columns: [{
                        checkbox: true
                    },
                        {
                            field: 'id',
                            title: '编号',
                            visible: false
                        },
                        {
                            field: 'gouhuoDanhao',
                            title: '单据编号'
                        },
                        {
                            field: 'gouhuoDate',
                            title: '购货日期'
                        },
                        {
                            field: 'gouhuoJingshouren',
                            title: '经手人'
                        },
                        {
                            field: 'gouhuoCangku',
                            title: '仓库',
                            formatter: function (value, row, index) {
                                return $.table.selectDictLabel(cangkuNameDatas, value);
                            }
                        },
                        {
                            field: 'goodId',
                            title: '商品编号'
                        },
                        {
                            field: 'shangpinLeibie',
                            title: '商品类别'
                        },
                        {
                            field: 'goodName',
                            title: '商品名称'
                        },
                        {
                            field: 'goodGuige',
                            title: '商品规格'
                        },
                        {
                            field: 'shuliang',
                            title: '数量'
                        },
                        {
                            field: 'zongbudijia',
                            title: '总部底价'
                        },
                        {
                            field: 'dijia',
                            title: '底价'
                        },
                        {
                            field: 'jiner',
                            title: '金额'
                        },
                        {
                            field: 'beizhu',
                            title: '备注'
                        },
                        /*{
                            title: '操作',
                            align: 'center',
                            formatter: function (value, row, index) {
                                var actions = [];
                                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                                return actions.join('');
                            }
                        }*/
                    ]
                };
                $.table.init(options);
                console.log(document.getElementById("session2value").innerText)
            });
        }
    })


</script>
</body>
</html>